package dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Scanner;

public class TestPage {
    public static void main(String[] args) {
        System.out.println("点击任意键显示下一页");
        int index =1;//表示页数
        int size =3;//表示行数
        Scanner sc =new Scanner(System.in);

        EmpDAO dao =new EmpDAO();
        while (true){
            String anyKey=sc.next();
            try {
                if(!anyKey.equalsIgnoreCase("n")){
                    List<Emp> list = dao.page(index,size);
                    for (int i = 0; i <list.size() ; i++) {
                        System.out.println(list.get(i).getName()+"----"+list.get(i).getDeptId());
                    }
                    //准备下一页的页码
                    index++;
                }else {
                    //如果输入字符n 就退出死循环
                    break;
                }
            } catch (ClassCastException | SQLException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }

    }
}
